﻿using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

namespace Project02
{
    class Driver:Object
    {
        private Vector2 carLocation;
        public Vector2 CarLocation
        {
            get { return carLocation; }
            set { carLocation = value; }
        }

        public Driver(Vector2 dimension, Vector2 location, int mass, GraphicsDevice graphicDevice)
            : base(dimension, location, mass, graphicDevice)
        {
            ObjTexture = CreateRectangle((int)dimension.X, (int)dimension.Y, Color.Olive);            
        }

        public void Update(InputListener inputListener)
        {
            //if (inputListener.isKeyPressed(Keys.A) && Location.X > CarLocation.X + 100)
            //{
            //    Position -= new Vector2(10, 0);
            //    Location -= new Vector2(10, 0);
            //    XCoorPosition -= new Vector2(10, 0);
            //    YCoorPosition -= new Vector2(10, 0);
            //}
            //if (inputListener.isKeyPressed(Keys.D) && Location.X < CarLocation.X + 100 + 40)
            //{
            //    Position += new Vector2(10, 0);
            //    Location += new Vector2(10, 0);
            //    XCoorPosition += new Vector2(10, 0);
            //    YCoorPosition += new Vector2(10, 0);
            //}
            //if (inputListener.isKeyPressed(Keys.W) && Mass < 200)
            //    Mass += 10;
            //if (inputListener.isKeyPressed(Keys.S) && Mass > 100)
            //    Mass -= 10;
        }

        public void Draw(SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(ObjTexture, Position + OffSet, null, Color.White, 0f, Origin, 1f, SpriteEffects.None, 0f);
            spriteBatch.Draw(AxisX, Position + OffSet, null, Color.White, 0f, new Vector2(Origin.X, 1), 1f, SpriteEffects.None, 0f);
            spriteBatch.Draw(AxisY, Position + OffSet, null, Color.White, MathHelper.PiOver2, new Vector2(Origin.Y, 1), 1f, SpriteEffects.None, 0f);
        }
    }
}
